<template>
  <div id="app">
    <el-container>
      <el-header>
        <el-menu class="el-menu-demo" router mode="horizontal" v-if="show">
          <el-menu-item index="/home">首页</el-menu-item>
          <el-menu-item index="/shang">商品</el-menu-item>
          <el-menu-item index="/ding">订单</el-menu-item>
          <el-menu-item>会员</el-menu-item>
          <el-menu-item>设置</el-menu-item>
            <el-button type="success" class="btn" @click="exit"
            >退出登录</el-button>
        </el-menu>
      </el-header>
      <el-container>
        <router-view></router-view>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      show: false,
    };
  },
  // 监听   如果是登录页面就隐藏
  watch: {
    "$route.path": {
      handler(newval, oldval) {
        if (newval == "/login") {
          this.show = false;
        } else {
          this.show = true;
        }
      },
    },
  },
        methods: {
        // 退出登录
    exit() {
      localStorage.removeItem("token");
      this.$router.push({ path: "/login" });
      this.$http(
        "http://ceshi5.dishait.cn/admin/logout",
        "post"
      ).then((res) => {});
    },
  },
};
</script>
<style scoped>
.el-header,
.el-footer {
  color: #333;
  text-align: center;
  line-height: 60px;
}

body > .el-container {
  margin-bottom: 40px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}
.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.btn{
  float: right;
  margin-top:10px;
  margin-right: 100px;
}
</style>